package com.qidianit.demo;

/**
 * @author 戴着假发的程序员
 * @company 起点编程
 * @date 2025/7/25 15:11
 * @description
 */
public class ThreadA extends Thread{
    private String wc;
    private String paper;

    public ThreadA(String wc, String paper) {
        this.wc = wc;
        this.paper = paper;
    }

    @Override
    public void run() {
        String name = Thread.currentThread().getName();
        synchronized (wc){
            System.out.println(name + "进入了厕所....");
            synchronized (paper){
                System.out.println(name + "得到了厕纸.....");
                System.out.println(name + "出去了厕所.....");
            }

        }
    }
}
